﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Enterprise.Management.Data;
using Enterprise.Management.ViewModels;

namespace Enterprise.Management.Business
{
    public class BIBLL : BaseBLL
    {
        public DP_Basic_Info GetBasicInfo(int ctgrID)
        {
            return DataContext.DP_Basic_Info.FirstOrDefault(m => m.BscInf_CtgrID == ctgrID);
        }

        public DP_User GetUser(int ctgrID)
        {
            return DataContext.DP_User.FirstOrDefault(m => m.User_CtgrID == ctgrID && m.User_Status == (int)StatusType.Valid);
        }

        public void AddBasicInfo(DP_Basic_Info dp_basic_info)
        {
            DataContext.DP_Basic_Info.InsertOnSubmit(dp_basic_info);
            DataContext.SubmitChanges();
        }

        internal void UpdateBasicInfo(UpdateBIViewModel vmUpdateBI)
        {
            DP_Basic_Info basic_info = DataContext.DP_Basic_Info.First(m => m.BscInf_CtgrID == vmUpdateBI.BscInf_CtgrID);

            basic_info.BscInf_Address = vmUpdateBI.BscInf_Address;
            basic_info.BscInf_Area = vmUpdateBI.BscInf_Area;
            basic_info.BscInf_Bianma = vmUpdateBI.BscInf_Bianma;
            basic_info.BscInf_BrokerNum = vmUpdateBI.BscInf_BrokerNum;
            basic_info.BscInf_DeptLevel = vmUpdateBI.BscInf_DeptLevel;
            basic_info.BscInf_DeptName = vmUpdateBI.BscInf_DeptName;
            basic_info.BscInf_DeputyManagerDangPifuDate = vmUpdateBI.BscInf_DeputyManagerDangPifuDate;
            basic_info.BscInf_DeputyManagerEmail = vmUpdateBI.BscInf_DeputyManagerEmail;
            basic_info.BscInf_DeputyManagerMobile = vmUpdateBI.BscInf_DeputyManagerMobile;
            basic_info.BscInf_DeputyManagerName = vmUpdateBI.BscInf_DeputyManagerName;
            basic_info.BscInf_DeputyManagerTel = vmUpdateBI.BscInf_DeputyManagerTel;
            basic_info.BscInf_DijiXzq = vmUpdateBI.BscInf_DijiXzq;
            basic_info.BscInf_DOB = vmUpdateBI.BscInf_DOB;
            basic_info.BscInf_EmpTotalNum = vmUpdateBI.BscInf_EmpTotalNum;
            basic_info.BscInf_Fax = vmUpdateBI.BscInf_Fax;
            basic_info.BscInf_InovationBusinessContactEmail = vmUpdateBI.BscInf_InovationBusinessContactEmail;
            basic_info.BscInf_InovationBusinessContactMobile = vmUpdateBI.BscInf_InovationBusinessContactMobile;
            basic_info.BscInf_InovationBusinessContactName = vmUpdateBI.BscInf_InovationBusinessContactName;
            basic_info.BscInf_InovationBusinessContactTel = vmUpdateBI.BscInf_InovationBusinessContactTel;
            basic_info.BscInf_InvestAdvisorDangPifuDate = vmUpdateBI.BscInf_InvestAdvisorDangPifuDate;
            basic_info.BscInf_InvestAdvisorDirectorEmail = vmUpdateBI.BscInf_InvestAdvisorDirectorEmail;
            basic_info.BscInf_InvestAdvisorDirectorMobile = vmUpdateBI.BscInf_InvestAdvisorDirectorMobile;
            basic_info.BscInf_InvestAdvisorDirectorName = vmUpdateBI.BscInf_InvestAdvisorDirectorName;
            basic_info.BscInf_InvestAdvisorDirectorTel = vmUpdateBI.BscInf_InvestAdvisorDirectorTel;
            basic_info.BscInf_InvestAdvisorNum = vmUpdateBI.BscInf_InvestAdvisorNum;
            basic_info.BscInf_JichuBianzhi = vmUpdateBI.BscInf_JichuBianzhi;
            basic_info.BscInf_JigouBianma = vmUpdateBI.BscInf_JigouBianma;
            basic_info.BscInf_JingjirenYewuDate = vmUpdateBI.BscInf_JingjirenYewuDate;
            basic_info.BscInf_KuozhanBianzhi = vmUpdateBI.BscInf_KuozhanBianzhi;
            basic_info.BscInf_ManagerDangPifuDate = vmUpdateBI.BscInf_ManagerDangPifuDate;
            basic_info.BscInf_ManagerEmail = vmUpdateBI.BscInf_ManagerEmail;
            basic_info.BscInf_ManagerMobile = vmUpdateBI.BscInf_ManagerMobile;
            basic_info.BscInf_ManagerName = vmUpdateBI.BscInf_ManagerName;
            basic_info.BscInf_ManagerTel = vmUpdateBI.BscInf_ManagerTel;
            basic_info.BscInf_MarketDirectorDangPifuDate = vmUpdateBI.BscInf_MarketDirectorDangPifuDate;
            basic_info.BscInf_MarketDirectorEmail = vmUpdateBI.BscInf_MarketDirectorEmail;
            basic_info.BscInf_MarketDirectorMobile = vmUpdateBI.BscInf_MarketDirectorMobile;
            basic_info.BscInf_MarketDirectorName = vmUpdateBI.BscInf_MarketDirectorName;
            basic_info.BscInf_MarketDirectorTel = vmUpdateBI.BscInf_MarketDirectorTel;
            basic_info.BscInf_MarketingNum = vmUpdateBI.BscInf_MarketingNum;
            basic_info.BscInf_OfficialStaffNum = vmUpdateBI.BscInf_OfficialStaffNum;
            basic_info.BscInf_OperationDirectorDangPifuDate = vmUpdateBI.BscInf_OperationDirectorDangPifuDate;
            basic_info.BscInf_OperationDirectorEmail = vmUpdateBI.BscInf_OperationDirectorEmail;
            basic_info.BscInf_OperationDirectorMobile = vmUpdateBI.BscInf_OperationDirectorMobile;
            basic_info.BscInf_OperationDirectorName = vmUpdateBI.BscInf_OperationDirectorName;
            basic_info.BscInf_OperationDirectorTel = vmUpdateBI.BscInf_OperationDirectorTel;
            basic_info.BscInf_QihuoIBDate = vmUpdateBI.BscInf_QihuoIBDate;
            basic_info.BscInf_RntlPrpt = vmUpdateBI.BscInf_RntlPrpt;
            basic_info.BscInf_ServiceWorkerNum = vmUpdateBI.BscInf_ServiceWorkerNum;
            basic_info.BscInf_ShuangRongDate = vmUpdateBI.BscInf_ShuangRongDate;
            basic_info.BscInf_TelCmpl = vmUpdateBI.BscInf_TelCmpl;
            basic_info.BscInf_TelCnsl = vmUpdateBI.BscInf_TelCnsl;
            basic_info.BscInf_TelDlgt = vmUpdateBI.BscInf_TelDlgt;
            basic_info.BscInf_XianjiXzq = vmUpdateBI.BscInf_XianjiXzq;
            basic_info.BscInf_Xiaqu = vmUpdateBI.BscInf_Xiaqu;
            basic_info.BscInf_ZipCode = vmUpdateBI.BscInf_ZipCode;

            DataContext.SubmitChanges();
        }
    }
}